bitkeeper revision 1.1159.187.64 (41bec5b2hEqxDdXD0_RNHHR7utG6gA)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Tue, 14 Dec 2004 10:51:30 +0000 (10:51 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Tue, 14 Dec 2004 10:51:30 +0000 (10:51 +0000)
schedule_tail is now an indirect function call in x86 architecture.

14 files changed:
.rootkeys
xen/arch/x86/boot/x86_64.S
xen/arch/x86/domain.c
xen/arch/x86/setup.c
xen/arch/x86/smpboot.c
xen/arch/x86/x86_32/entry.S
xen/common/domain.c
xen/include/asm-x86/domain.h [deleted file]
xen/include/asm-x86/processor.h
xen/include/asm-x86/system.h
xen/include/asm-x86/x86_32/current.h
xen/include/asm-x86/x86_64/current.h
xen/include/xen/domain.h [new file with mode: 0644]
xen/include/xen/sched.h

index 87bb718abb56d1fc1f5f2d271579663ac17a9407..b8615ff886645644879cbd25776961fbd3110e3b 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
 3ddb79c3r9-31dIsewPV3P3i8HALsQ xen/include/asm-x86/delay.h
 3ddb79c34BFiXjBJ_cCKB0aCsV1IDw xen/include/asm-x86/desc.h
 40715b2dTokMLYGSuD58BnxOqyWVew xen/include/asm-x86/div64.h
-40f2b4a2hC3HtChu-ArD8LyojxWMjg xen/include/asm-x86/domain.h
 3e20b82fl1jmQiKdLy7fxMcutfpjWA xen/include/asm-x86/domain_page.h
 3ddb79c3NU8Zy40OTrq3D-i30Y3t4A xen/include/asm-x86/fixmap.h
 3e2d29944GI24gf7vOP_7x8EyuqxeA xen/include/asm-x86/flushtlb.h
 3eb165e0eawr3R-p2ZQtSdLWtLRN_A xen/include/xen/console.h
 3ddb79c1V44RD26YqCUm-kqIupM37A xen/include/xen/ctype.h
 3ddb79c05DdHQ0UxX_jKsXdR4QlMCA xen/include/xen/delay.h
+40f2b4a2hC3HtChu-ArD8LyojxWMjg xen/include/xen/domain.h
 3ddb79c2O729EttZTYu1c8LcsUO_GQ xen/include/xen/elf.h
 3ddb79c0HIghfBF8zFUdmXhOU8i6hA xen/include/xen/errno.h
 3ddb79c1W0lQca8gRV7sN6j3iY4Luw xen/include/xen/event.h
index 98289c7ab656e07bfddfa654f7630bddd773d345..b16cde876204100e845ae8fc5dfe37ba6ef725e5 100644 (file)
@@ -270,9 +270,8 @@ copy_user_generic:
 memcmp:
 idt_tables:
 new_thread:
-.globl switch_to, continue_nonidle_task, __get_user_1, paging_init, trap_init
+.globl switch_to, __get_user_1, paging_init, trap_init
 switch_to:
-continue_nonidle_task:
 __get_user_1:
 paging_init:
 trap_init: 
index 4a01d86351208139f88a829f64d8ad2ca543bd35..1881afa3fd42cd7c4d48721f5d2bfb9bf00f1580 100644 (file)
 #define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
 #define round_pgdown(_p)  ((_p)&PAGE_MASK)
 
-int hlt_counter;
-
-void disable_hlt(void)
-{
-    hlt_counter++;
-}
-
-void enable_hlt(void)
-{
-    hlt_counter--;
-}
-
-/*
- * We use this if we don't have any better
- * idle routine..
- */
 static void default_idle(void)
 {
-    if ( hlt_counter == 0 )
-    {
-        __cli();
-        if ( !softirq_pending(smp_processor_id()) )
-            safe_halt();
-        else
-            __sti();
-    }
+    __cli();
+    if ( !softirq_pending(smp_processor_id()) )
+        safe_halt();
+    else
+        __sti();
 }
 
-void continue_cpu_idle_loop(void)
+static void idle_loop(void)
 {
     int cpu = smp_processor_id();
     for ( ; ; )
@@ -102,7 +83,7 @@ void startup_cpu_idle_loop(void)
     smp_mb();
     init_idle();
 
-    continue_cpu_idle_loop();
+    idle_loop();
 }
 
 static long no_idt[2];
@@ -216,20 +197,43 @@ void free_perdomain_pt(struct domain *d)
     free_xenheap_page((unsigned long)d->mm.perdomain_pt);
 }
 
+static void continue_idle_task(struct domain *d)
+{
+    reset_stack_and_jump(idle_loop);
+}
+
+static void continue_nonidle_task(struct domain *d)
+{
+    reset_stack_and_jump(ret_from_intr);
+}
+
 void arch_do_createdomain(struct domain *d)
 {
-    d->shared_info = (void *)alloc_xenheap_page();
-    memset(d->shared_info, 0, PAGE_SIZE);
-    d->shared_info->arch.mfn_to_pfn_start = 
-       virt_to_phys(&machine_to_phys_mapping[0])>>PAGE_SHIFT;
-    SHARE_PFN_WITH_DOMAIN(virt_to_page(d->shared_info), d);
-    machine_to_phys_mapping[virt_to_phys(d->shared_info) >> 
-                           PAGE_SHIFT] = INVALID_P2M_ENTRY;
-
-    d->mm.perdomain_pt = (l1_pgentry_t *)alloc_xenheap_page();
-    memset(d->mm.perdomain_pt, 0, PAGE_SIZE);
-    machine_to_phys_mapping[virt_to_phys(d->mm.perdomain_pt) >> 
-                           PAGE_SHIFT] = INVALID_P2M_ENTRY;
+#ifdef ARCH_HAS_FAST_TRAP
+    SET_DEFAULT_FAST_TRAP(&d->thread);
+#endif
+
+    if ( d->id == IDLE_DOMAIN_ID )
+    {
+        d->thread.schedule_tail = continue_idle_task;
+    }
+    else
+    {
+        d->thread.schedule_tail = continue_nonidle_task;
+
+        d->shared_info = (void *)alloc_xenheap_page();
+        memset(d->shared_info, 0, PAGE_SIZE);
+        d->shared_info->arch.mfn_to_pfn_start = 
+            virt_to_phys(&machine_to_phys_mapping[0])>>PAGE_SHIFT;
+        SHARE_PFN_WITH_DOMAIN(virt_to_page(d->shared_info), d);
+        machine_to_phys_mapping[virt_to_phys(d->shared_info) >> 
+                               PAGE_SHIFT] = INVALID_P2M_ENTRY;
+
+        d->mm.perdomain_pt = (l1_pgentry_t *)alloc_xenheap_page();
+        memset(d->mm.perdomain_pt, 0, PAGE_SIZE);
+        machine_to_phys_mapping[virt_to_phys(d->mm.perdomain_pt) >> 
+                               PAGE_SHIFT] = INVALID_P2M_ENTRY;
+    }
 }
 
 int arch_final_setup_guestos(struct domain *d, full_execution_context_t *c)
@@ -263,7 +267,6 @@ int arch_final_setup_guestos(struct domain *d, full_execution_context_t *c)
            sizeof(d->thread.traps));
 
 #ifdef ARCH_HAS_FAST_TRAP
-    SET_DEFAULT_FAST_TRAP(&d->thread);
     if ( (rc = (int)set_fast_trap(d, c->fast_trap_idx)) != 0 )
         return rc;
 #endif
@@ -328,9 +331,6 @@ void new_thread(struct domain *d,
 
     __save_flags(ec->eflags);
     ec->eflags |= X86_EFLAGS_IF;
-
-    /* No fast trap at start of day. */
-    SET_DEFAULT_FAST_TRAP(&d->thread);
 }
 
 
index cf6f7980e15621aad151afa8c2b838a3a1cffd95..d2109f4fb82a18c1b03109ccbcf624f920f2ab4d 100644 (file)
@@ -328,6 +328,8 @@ void __init start_of_day(void)
 
     sort_exception_tables();
 
+    arch_do_createdomain(current);
+
     /* Tell the PCI layer not to allocate too close to the RAM area.. */
     low_mem_size = ((max_page << PAGE_SHIFT) + 0xfffff) & ~0xfffff;
     if ( low_mem_size > pci_mem_start ) pci_mem_start = low_mem_size;
index 05d49a27d03fd0f5bc2d470f9c37e29ed56af574..991b5c577a93390bd20ffff7b7fa001d652896e2 100644 (file)
@@ -662,10 +662,6 @@ static void __init do_boot_cpu (int apicid)
 
     map_cpu_to_boot_apicid(cpu, apicid);
 
-#if defined(__i386__)
-    SET_DEFAULT_FAST_TRAP(&idle->thread);
-#endif
-
     idle_task[cpu] = idle;
 
     /* start_eip had better be page-aligned! */
index c85d84c649edc857370676be7d751e16e8282dbe..a3ed040538c7107ed9f34cecbb41156343bc07d6 100644 (file)
         andl $~3,reg;      \
         movl (reg),reg;
 
-ENTRY(continue_nonidle_task)
-        GET_CURRENT(%ebx)
-        jmp test_all_events
-
         ALIGN
 restore_all_guest:
         testb $TF_failsafe_return,DOMAIN_thread_flags(%ebx)
index d4a97d307a41df52248bb6285b6ed9661ec88226..ed18817cec252f661dc7186cbde3917665f39e2b 100644 (file)
@@ -47,20 +47,21 @@ struct domain *do_createdomain(domid_t dom_id, unsigned int cpu)
     /* Per-domain PCI-device list. */
     spin_lock_init(&d->pcidev_lock);
     INIT_LIST_HEAD(&d->pcidev_list);
+    
+    if ( (d->id != IDLE_DOMAIN_ID) &&
+         ((init_event_channels(d) != 0) || (grant_table_create(d) != 0)) )
+    {
+        destroy_event_channels(d);
+        free_domain_struct(d);
+        return NULL;
+    }
+    
+    arch_do_createdomain(d);
+    
+    sched_add_domain(d);
 
     if ( d->id != IDLE_DOMAIN_ID )
     {
-        if ( (init_event_channels(d) != 0) || (grant_table_create(d) != 0) )
-        {
-            destroy_event_channels(d);
-            free_domain_struct(d);
-            return NULL;
-        }
-
-        arch_do_createdomain(d);
-
-        sched_add_domain(d);
-
         write_lock(&domlist_lock);
         pd = &domain_list; /* NB. domain_list maintained in order of dom_id. */
         for ( pd = &domain_list; *pd != NULL; pd = &(*pd)->next_list )
@@ -72,10 +73,6 @@ struct domain *do_createdomain(domid_t dom_id, unsigned int cpu)
         domain_hash[DOMAIN_HASH(dom_id)] = d;
         write_unlock(&domlist_lock);
     }
-    else
-    {
-        sched_add_domain(d);
-    }
 
     return d;
 }
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
deleted file mode 100644 (file)
index 7dde4ef..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-
-#ifndef __ASM_X86_DOMAIN_H__
-#define __ASM_X86_DOMAIN_H__
-
-extern void arch_do_createdomain(struct domain *d);
-
-extern int  arch_final_setup_guestos(
-    struct domain *d, full_execution_context_t *c);
-
-extern void free_perdomain_pt(struct domain *d);
-
-extern void domain_relinquish_memory(struct domain *d);
-
-#endif /* __ASM_X86_DOMAIN_H__ */
index c5ccb59fa350957111289fd56485408450cfff96..6d3cf3036a5bed22eab3f6a1ba5d60f9d62247b7 100644 (file)
@@ -399,6 +399,8 @@ struct thread_struct {
     /* general user-visible register state */
     execution_context_t user_ctxt;
 
+    void (*schedule_tail) (struct domain *);
+
     /*
      * Return vectors pushed to us by guest OS.
      * The stack frame for events is exactly that of an x86 hardware interrupt.
@@ -456,14 +458,10 @@ extern struct desc_struct *idt_tables[];
 
 long set_fast_trap(struct domain *p, int idx);
 
-#define INIT_THREAD  { fast_trap_idx: 0x20 }
-
-#elif defined(__x86_64__)
+#endif
 
 #define INIT_THREAD { 0 }
 
-#endif /* __x86_64__ */
-
 extern int gpf_emulate_4gb(struct xen_regs *regs);
 
 struct mm_struct {
index e2c961e360cb5ef467776b8e6183952c79164e53..18854edc3ff2a372430ddaf06e55d43714b1a929 100644 (file)
@@ -271,13 +271,6 @@ static inline int local_irq_is_enabled(void)
     return !!(flags & (1<<9)); /* EFLAGS_IF */
 }
 
-/*
- * disable hlt during certain critical i/o operations
- */
-#define HAVE_DISABLE_HLT
-void disable_hlt(void);
-void enable_hlt(void);
-
 #define BROKEN_ACPI_Sx         0x0001
 #define BROKEN_INIT_AFTER_S1   0x0002
 
index 3450cd02cc8ea52f9342f730d236a230f61d9b18..2c76a133aaca4c7576658c0bb1c28d4ba731d515 100644 (file)
@@ -45,14 +45,11 @@ static inline unsigned long get_stack_top(void)
     return p;
 }
 
-#define schedule_tail(_p)                                         \
+#define reset_stack_and_jump(__fn)                                \
     __asm__ __volatile__ (                                        \
-        "andl %%esp,%0; addl %2,%0; movl %0,%%esp; jmp *%1"       \
-        : : "r" (~(STACK_SIZE-1)),                                \
-            "r" (unlikely(is_idle_task((_p))) ?                   \
-                                continue_cpu_idle_loop :          \
-                                continue_nonidle_task),           \
-            "i" (STACK_SIZE-STACK_RESERVED) )
+        "movl %0,%%esp; jmp "STR(__fn)                            \
+        : : "r" (get_execution_context()) )
 
+#define schedule_tail(_d) ((_d)->thread.schedule_tail)(_d)
 
 #endif /* _X86_CURRENT_H */
index 2f3a6e5665607e1780e130d47f9abc2b9aafb355..2ee550643b989ad48ed76283860357e7f33f34b4 100644 (file)
@@ -40,15 +40,12 @@ static inline unsigned long get_stack_top(void)
     return p;
 }
 
-#define schedule_tail(_p)                                         \
+#define reset_stack_and_jump(__fn)                                \
     __asm__ __volatile__ (                                        \
-        "andq %%rsp,%0; addq %2,%0; movq %0,%%rsp; jmp *%1"       \
-        : : "r" (~(STACK_SIZE-1)),                                \
-            "r" (unlikely(is_idle_task((_p))) ?                   \
-                                continue_cpu_idle_loop :          \
-                                continue_nonidle_task),           \
-            "i" (STACK_SIZE-STACK_RESERVED) )
+        "movq %0,%%rsp; jmp "STR(__fn)                            \
+        : : "r" (get_execution_context()) )
 
+#define schedule_tail(_d) ((_d)->thread.schedule_tail)(_d)
 
 #else
 
diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h
new file mode 100644 (file)
index 0000000..5ff5ed6
--- /dev/null
@@ -0,0 +1,20 @@
+
+#ifndef __XEN_DOMAIN_H__
+#define __XEN_DOMAIN_H__
+
+
+
+/*
+ * Arch-specifics.
+ */
+
+extern void arch_do_createdomain(struct domain *d);
+
+extern int  arch_final_setup_guestos(
+    struct domain *d, full_execution_context_t *c);
+
+extern void free_perdomain_pt(struct domain *d);
+
+extern void domain_relinquish_memory(struct domain *d);
+
+#endif /* __XEN_DOMAIN_H__ */
index c8781f0440b3e974be19b73996d92dcbe606f448..d7e6f0be26edb0f3f7f7229ad5f711ceef2b4a9b 100644 (file)
@@ -214,9 +214,6 @@ void domain_init(void);
 int idle_cpu(int cpu); /* Is CPU 'cpu' idle right now? */
 
 void startup_cpu_idle_loop(void);
-void continue_cpu_idle_loop(void);
-
-void continue_nonidle_task(void);
 
 unsigned long hypercall_create_continuation(
     unsigned int op, unsigned int nr_args, ...);
@@ -295,6 +292,6 @@ static inline void domain_unpause_by_systemcontroller(struct domain *d)
 #define VM_ASSIST(_d,_t) (test_bit((_t), &(_d)->vm_assist))
 
 #include <xen/slab.h>
-#include <asm/domain.h>
+#include <xen/domain.h>
 
 #endif /* __SCHED_H__ */